package com.sky.exception;

import com.sky.Result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler(value = CustomException.class)
    public Result customExceptionHandler(CustomException e) {
        log.error("捕获到自定义异常：{}", e.getMessage());
        return Result.error(e.getMessage());
    }
}
